<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Calculate the soundex key of a string</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.soundex" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">soundex</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">soundex</span> &mdash; <span class="dc-title">Calculate the soundex key of a string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.soundex-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>soundex</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   Calculates the soundex key of <code class="parameter">str</code>.
  </p>
  <p class="para">
   Soundex keys have the property that words pronounced similarly
   produce the same soundex key, and can thus be used to simplify
   searches in databases where you know the pronunciation but not
   the spelling. This soundex function returns a string 4 characters
   long, starting with a letter.
  </p>
  <p class="para">
   This particular soundex function is one described by Donald Knuth
   in &quot;The Art Of Computer Programming, vol. 3: Sorting And
   Searching&quot;, Addison-Wesley (1973), pp. 391-392.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.soundex-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">str</code></dt>

     <dd>

      <p class="para">
       The input string.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.soundex-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the soundex key as a string.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.soundex-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5939">
    <p><strong>Example #1 Soundex Examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Euler"</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==&nbsp;</span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ellery"</span><span style="color: #007700">);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;E460<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Gauss"</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==&nbsp;</span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ghosh"</span><span style="color: #007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;G200<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Hilbert"</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==&nbsp;</span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Heilbronn"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;H416<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Knuth"</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==&nbsp;</span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Kant"</span><span style="color: #007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;K530<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lloyd"</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==&nbsp;</span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ladd"</span><span style="color: #007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;L300<br /></span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lukasiewicz"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #0000BB">soundex</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lissajous"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;L222<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.soundex-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="levenshtein.html" class="function" rel="rdfs-seeAlso">levenshtein()</a> - 计算两个字符串之间的编辑距离</span></li>
    <li class="member"><span class="function"><a href="metaphone.html" class="function" rel="rdfs-seeAlso">metaphone()</a> - Calculate the metaphone key of a string</span></li>
    <li class="member"><span class="function"><a href="similar_text.html" class="function" rel="rdfs-seeAlso">similar_text()</a> - 计算两个字符串的相似度</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>